#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<stack>
using namespace std;
class MyQueue {
public:
    MyQueue() {

    }

    void push(int x) {
        st1.push(x);
    }

    int pop()
    {
        while (st2.empty())
        {
            while (!st1.empty())
            {
                int x = st1.top();
                st1.pop();
                st2.push(x);
            }
        }
        int x = st2.top();
        st2.pop();
        return x;
    }

    int peek() {
        while (st2.empty())
        {
            while (!st1.empty())
            {
                int x = st1.top();
                st1.pop();
                st2.push(x);
            }
        }
        return st2.top();;
    }

    bool empty() {
        return st2.empty() && st1.empty();
    }
private:
    stack<int>st1;
    stack<int>st2;
};